<?php
	class GenErr
	{
		public $page = null;
		
		public function __construct(&$page)
		{
			$this->page = &$page;
			
			// Do this at the construction of GenErr to elminate use for run()
			if( isset( $this->page->core->configs['error'] ) )
			{
				// Assign a value to exc
				$this->page->assign( 'exc', null );
				
				// This is dangerous.. but not likely to happen, though a very recursive (infinite) loop may occur
				try
				{
					// Different output for exceptions
					if($this->page->core->configs['error']['num'] === 'exception')
					{
						$this->page->assign( 'exc', 'true' );
					}
					else
					{
						$this->page->assign('file', $this->page->core->configs['error']['file']);
						$this->page->assign('num', $this->page->core->configs['error']['num']);
						$this->page->assign('line', $this->page->core->configs['error']['line']);						
					}
					
					$this->page->assign('error', $this->page->core->configs['error']['message']);
				}
				catch(Exception $e)
				{
					// This is the dangerous part, if this fails, it's likely to fail again (hopefully not)
					$this->page->core->general_error_handler($e->getMessage());
				}
			}
			else
			{
				// not here to correct mistakes, lets just show an error
				//$this->page->core->general_error_handler('NGen:GeneralError -> No error to report');
			}
		}
		
		/**
		 * @deprecated
		 * No use for run() in a general error instance
		 */
		//public function run()
		//{
		//	
		//}
	}
?>